<template>
    <div>
        <van-nav-bar title="更新昵称" left-text="取消" right-text="报存" left-arrow @click-left="onClickLeft"
            @click-right="onClickRight" />
        <van-field v-model="nickname" rows="2" autosize type="textarea" maxlength="11" placeholder="请输入昵称"
            show-word-limit />
    </div>
</template>

<script>
import { aditUserProfileAPI } from '@/api'
export default {
    props: {
        name: {
            type: String,
            required: true
        }
    },
    data() {
        return {
            nickname: this.name
        }
    },
    methods: {
        onClickLeft() {
            this.$emit('close')
        },
        async onClickRight() {
            await aditUserProfileAPI({
                name: this.nickname
            })
            this.$emit('updata:name', this.nickname)
            this.$emit('close')
            this.$toast.success('更新成功')
        }
    }
}
</script>

<style>

</style>